import Vue from 'vue'
import VueRouter from 'vue-router'
const originalPush = VueRouter.prototype.push
const originalReplace = VueRouter.prototype.replace
// push
VueRouter.prototype.push = function push (location, onResolve, onReject) {
    if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
    return originalPush.call(this, location).catch(err => err)
}
// replace
VueRouter.prototype.replace = function push (location, onResolve, onReject) {
    if (onResolve || onReject) return originalReplace.call(this, location, onResolve, onReject)
    return originalReplace.call(this, location).catch(err => err)
}


Vue.use(VueRouter)
import index from './index.vue'
import floor from './floor.vue'
import screen from './screen.vue'
import test from './test.vue'

const routes = [
    {
        path: '/',
        redirect: 'index'
    },
    {
        path: '*',
        redirect: '/'
    },
    {
        path: '/index',
        name: 'index',
        component: index
    },
    {
        path: '/floor',
        name: 'floor',
        component: floor
    },
    {
        path: '/screen',
        name: 'screen',
        component: screen
    },
    {
        path: '/test',
        name: 'test',
        component: test
    },
]

export default new VueRouter({
    routes
})
